package com.techsen.tsweb.sys.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.techsen.tsweb.core.service.impl.BaseService;
import com.techsen.tsweb.sys.dao.MenuDao;
import com.techsen.tsweb.sys.domain.Menu;
import com.techsen.tsweb.sys.service.MenuService;

@Service
public class MenuServiceImpl extends BaseService<Menu, MenuDao> implements MenuService {

    @Resource @Override
    public void setDao(MenuDao dao) {
        this.dao = dao;
    }
    
    /**
     * 根据父菜单ID获取所有子菜单
     */
    @Override
    public List<Menu> getAllChildrenMenu(String id) {
        return this.dao.getAllChildrenMenu(id);
    }
    
    /**
     * 根据父菜单ID获取所有子菜单
     */
    @Override
    public List<String> getAllChildrenMenuId(String id) {
        return this.dao.getAllChildrenMenuId(id);
    }
    
    /**
     * 根据用户ID获取授权给这个用户的菜单资源ID集合<br/>
     * 1. 按用户授权<br/>
     * 2. 按角色授权<br/>
     */
    @Override
    public List<String> getAuthorizedMenuIdsByUserId(String userId) {
        return this.dao.getAuthorizedMenuIdsByUserId(userId);
    }
    
    /**
     * 根据用户ID获取授权给这个用户的菜单资源集合<br/>
     * 1. 按用户授权<br/>
     * 2. 按角色授权<br/>
     */
    @Override
    public List<Menu> getAuthorizedMenusByUserId(String userId) {
        return this.dao.getAuthorizedMenusByUserId(userId);
    }

}
